Solenoid valves for controlling a fuel flow, which comprise a housing that has an interior space in which is arranged an actuator that can be displaced into the interior space by means of a magnetic field, are known. In this case, the actuator is coupled to a valve body which is raised or lowered by the displacement of the actuator in order to open or close an outlet opening of the housing. In this case, the actuator forms in the interior space of the housing a leakage space which is filled with fuel during operation. Displacement of the actuator in the leakage space increases or reduces the volume thereof. Here, a pressure drop occurs in the leakage space when the volume is increased, leading to the occurrence of cavitation or the formation of fuel vapor bubbles in the leakage space. Upon contact with the surfaces of the housing and/or of the actuator, the cavitation causes cavitation pitting, which roughens the surface of the housing and/or of the actuator and, in the long term, destroys it owing to the high mechanical loads involved in cavitation at the surface.